index integer specifys for the n-th voicename you want the
name from. This index must be in the range one
(1) to the count returned by the SP Count
voices function (see above).
You can also pass the reference number obtained
from the SP Open Voice function. You can then
retrieve the name of the voice of that opened
speech channel which may be slightly different
from what you specified when calling
SP Open Voice. If the speech channel is
already closed an error will be returned (-244).
voice string (63) returns the voice name of the specified index or
reference.
err integer returns the error which occured.
A value of zero indicates no error occured. See
below for a list of possible errors.
Returns the name of a voice based on an index number or reference number.
Don't assume using index 1 returns always ”Marvin“. The index is the order in which the voices were found in the application and/or System Folder. After a restart this may have changed completely since the user can move, add or remove voice files.
When the user switches to the Finder and installs or removes voice files (the user should restart after doing this) the index value becomes invalid. So, don't store the index of a particular voice.
If you use the ”*“ wildcard as the voicename and you really want to know its real name, pass -2 as the index value and the name returned is that of the default voice.
The same applies when you want to know which voice is behind the ”#“ wildcard, then use -1 as the index value. Don't start a loop with -2 or -1 because you then will find the same voice twice.
Examples:
`if you make sure the $i variable in the range 1 to SP Count voices:
$err := SP Voicename ($i;$voicename)
`and to get the name of the default voice
$err := SP Voicename (-2;$voicename)
`if you want a random chosen voice:
`$count was filled with the number of voices using
`SP Count Voices (see above)
$err := SP Voicename (Random%$count+1;$voicename)
`to get the name of the voice of a open speech channel:
$err := SP Voicename ($speechref;$voicename)
`see also the example code with the SP Count Voices function
`for some reason this doesn't work:
ARRAY STRING (63;myArray;SP Count Voices)
$err := SP Voicename ($i;myArray{$i})
Possible errors:
0 No Error
-4 Speech Pack can not be used (Speech Mgr not available)
-50 Parameter error (inside external, not necessarily the
parameters you pass)
-108 Not enough memory to load voice into memory
-244 Voice resource not found (i.e. index out of range or channel